﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.GetData;
using TyMES.Model;

namespace TyMES.ViewModel.GetData.BadCodeTemplateVMs
{
    public partial class BadCodeTemplateListVM : BasePagedListVM<BadCodeTemplate_View, BadCodeTemplateSearcher>
    {
        
        protected override IEnumerable<IGridColumn<BadCodeTemplate_View>> InitGridHeader()
        {
            return new List<GridColumn<BadCodeTemplate_View>>{
                
                this.MakeGridHeader(x => x.BadCodeTemplate_addTime).SetTitle(@Localizer["Page.添加时间"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_badCode).SetTitle(@Localizer["Page.不良编码"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_badName).SetTitle(@Localizer["Page.不良名称"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_badTypeCode).SetTitle(@Localizer["Page.不良类型编码"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_badTypeName).SetTitle(@Localizer["Page.不良类型名称"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_dataStatus).SetTitle(@Localizer["Page.数据状态"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_editTime).SetTitle(@Localizer["Page.编辑时间"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_enableStatus).SetTitle(@Localizer["Page.启用状态"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_factoryCode).SetTitle(@Localizer["Page.工厂编码"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_field1).SetTitle(@Localizer["Page.预留域1"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_field2).SetTitle(@Localizer["Page.预留域2"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_field3).SetTitle(@Localizer["Page.预留域3"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_field4).SetTitle(@Localizer["Page.预留域4"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_field5).SetTitle(@Localizer["Page.预留域5"].Value),
                this.MakeGridHeader(x => x.BadCodeTemplate_operationCode).SetTitle(@Localizer["Page.工艺编码"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<BadCodeTemplate_View> GetSearchQuery()
        {
            var query = DC.Set<BadCodeTemplate>()
                
                .CheckBetween(Searcher.AddTime?.GetStartTime(), Searcher.AddTime?.GetEndTime(), x => x.AddTime, includeMax: false)
                .CheckContain(Searcher.BadCode, x=>x.BadCode)
                .CheckContain(Searcher.BadName, x=>x.BadName)
                .CheckContain(Searcher.BadTypeCode, x=>x.BadTypeCode)
                .CheckContain(Searcher.BadTypeName, x=>x.BadTypeName)
                .CheckContain(Searcher.DataStatus, x=>x.DataStatus)
                .CheckBetween(Searcher.EditTime?.GetStartTime(), Searcher.EditTime?.GetEndTime(), x => x.EditTime, includeMax: false)
                .CheckContain(Searcher.EnableStatus, x=>x.EnableStatus)
                .CheckContain(Searcher.FactoryCode, x=>x.FactoryCode)
                .CheckContain(Searcher.Field1, x=>x.Field1)
                .CheckContain(Searcher.Field2, x=>x.Field2)
                .CheckContain(Searcher.Field3, x=>x.Field3)
                .CheckContain(Searcher.Field4, x=>x.Field4)
                .CheckContain(Searcher.Field5, x=>x.Field5)
                .CheckContain(Searcher.OperationCode, x=>x.OperationCode)
                .Select(x => new BadCodeTemplate_View
                {
				    ID = x.ID,
                    
                    BadCodeTemplate_addTime = x.AddTime,
                    BadCodeTemplate_badCode = x.BadCode,
                    BadCodeTemplate_badName = x.BadName,
                    BadCodeTemplate_badTypeCode = x.BadTypeCode,
                    BadCodeTemplate_badTypeName = x.BadTypeName,
                    BadCodeTemplate_dataStatus = x.DataStatus,
                    BadCodeTemplate_editTime = x.EditTime,
                    BadCodeTemplate_enableStatus = x.EnableStatus,
                    BadCodeTemplate_factoryCode = x.FactoryCode,
                    BadCodeTemplate_field1 = x.Field1,
                    BadCodeTemplate_field2 = x.Field2,
                    BadCodeTemplate_field3 = x.Field3,
                    BadCodeTemplate_field4 = x.Field4,
                    BadCodeTemplate_field5 = x.Field5,
                    BadCodeTemplate_operationCode = x.OperationCode,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class BadCodeTemplate_View: BadCodeTemplate
    {
        
        public DateTime? BadCodeTemplate_addTime { get; set; }
        public string BadCodeTemplate_badCode { get; set; }
        public string BadCodeTemplate_badName { get; set; }
        public string BadCodeTemplate_badTypeCode { get; set; }
        public string BadCodeTemplate_badTypeName { get; set; }
        public string BadCodeTemplate_dataStatus { get; set; }
        public DateTime? BadCodeTemplate_editTime { get; set; }
        public string BadCodeTemplate_enableStatus { get; set; }
        public string BadCodeTemplate_factoryCode { get; set; }
        public string BadCodeTemplate_field1 { get; set; }
        public string BadCodeTemplate_field2 { get; set; }
        public string BadCodeTemplate_field3 { get; set; }
        public string BadCodeTemplate_field4 { get; set; }
        public string BadCodeTemplate_field5 { get; set; }
        public string BadCodeTemplate_operationCode { get; set; }

    }

}